package cn.imvc.app.repositories;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import cn.imvc.app.entities.Brand;
import cn.imvc.app.entities.Goods;
import cn.imvc.app.entities.GoodsClass;
import cn.imvc.data.jpa.repository.IJpqlExecutor;

public interface GoodsRepository  extends JpaRepository<Goods, Integer>,IJpqlExecutor<Goods>{
	List<Goods> findByGoodsClassAndBrand(GoodsClass goodsClass,Brand brand);
	
	@Query("select count(g) from GoodsSku g where g.state = :state and g.goods.id = :goodsid")
	int getGoodsSkuCountBySkuState(@Param("state")Byte state,@Param("goodsid")int goodsid);
	
	@Query("select count(g) from GoodsSku g where g.state in :states and g.goods.id = :goodsid")
	int getGoodsSkuCountBySkuStates(@Param("states")byte[] states,@Param("goodsid")int goodsid);
}
